import Router from "koa-router";
import hobbyModel from "./hobbyModel.js";
import studentModel from "../student/studentModel.js";
const router = Router({
  prefix: '/hobby'
})


router.post('/get', async (ctx, next) => {
  let res = await hobbyModel.findAll({
    attributes: ['id', 'name'],
    include: [
      {
        model: studentModel,
        attributes: ['name'],
        //这个配置是为了不显示中间表的字段
        through: {
          attributes: []
        }
      }
    ],
    where: {
      id: 2,
    }
  });

  ctx.body = res;
});


export default router;